package cn.rongdao.jrkabao.ui.loan.uicomponent;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.widget.InterceptorTouchEventRelativeLayout;


/**
 * Created by WANG on 17/11/6.
 */

public class LoanCommitSmallQuotaComponent extends InterceptorTouchEventRelativeLayout {
    private ImageView loancommit_smallquote_image;
    private TextView loancommit_smallquote_text;
    private TextView loancommit_smallquote_textDay;
    private TextView loancommit_smallquote_textMoney;

    public LoanCommitSmallQuotaComponent(Context context) {
        super(context);
    }

    public LoanCommitSmallQuotaComponent(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LoanCommitSmallQuotaComponent(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        this.setInterceptorTouchEvent(true);
        loancommit_smallquote_image = (ImageView) findViewById(R.id.loancommit_smallquote_image);
        loancommit_smallquote_image.setTag(true);
        loancommit_smallquote_text = (TextView) findViewById(R.id.loancommit_smallquote_text);
        loancommit_smallquote_textDay = (TextView) findViewById(R.id.loancommit_smallquote_textDay);
        loancommit_smallquote_textMoney = (TextView) findViewById(R.id.loancommit_smallquote_textMoney);
        click();
    }

    public void  setOwnVisible(boolean visible){
        if(visible) {
            setVisibility(VISIBLE);
        }else {
            setVisibility(GONE);
        }
    }

    public Boolean getOwnVisible(){
        int visibility = getVisibility();
        if(visibility == VISIBLE){
            return  true;
        }else {
            return  false;
        }
    }

    public void click(){

        loancommit_smallquote_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean tag = (boolean) loancommit_smallquote_image.getTag();
                if(tag){
                    loancommit_smallquote_image.setTag(false);
                    loancommit_smallquote_image.setImageResource(R.drawable.loancommit_smallquote_unselectedimage);
                }else {
                    loancommit_smallquote_image.setTag(true);
                    loancommit_smallquote_image.setImageResource(R.drawable.icon_loancommit_smallquota);

                }
            }
        });
    }
    public boolean getClickState(){
        return (boolean) loancommit_smallquote_image.getTag();
    }

    public void setSmallquoteDay(String text) {
        this.loancommit_smallquote_textDay.setText(text);
    }


    public void setSmallquoteMoney(String text) {
        this.loancommit_smallquote_textMoney.setText(text);
    }
}
